package cn.ibobo.lease.admin.service.impl;

import cn.ibobo.lease.admin.dao.ActivityMapper;
import cn.ibobo.lease.admin.service.ActivityService;
import cn.ibobo.lease.common.base.BaseMapper;
import cn.ibobo.lease.common.base.BaseServiceImpl;
import cn.ibobo.lease.common.dto.ActivityDTO;
import cn.ibobo.lease.common.util.DateUtil;
import cn.ibobo.lease.common.util.UuidUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * 活动信息业务处理接口
 * @Author lililiang
 * @Date 2019-02-20 19:18:47
 */
@Service
public class ActivityServiceImpl extends BaseServiceImpl<ActivityDTO, String> implements ActivityService {

    private static final Log LOGGER = LogFactory.getLog(ActivityServiceImpl.class);

    @Autowired
    private ActivityMapper mapper;

    @Override
    protected BaseMapper<ActivityDTO, String> getMapper() {
        return mapper;
    }

    /**
     * 活动信息列表
     * @Author lililiang
     * @Date 2019-02-20 19:18:47
     * @Param
     * @Return
     */
    @Override
    public List<ActivityDTO> list4Page(ActivityDTO entity, Integer pageNum, Integer... pageSize) {
        return super.list4Page(entity, pageNum, pageSize);
    }

    /**
     * 活动信息列表（无分页）
     * @Author lililiang
     * @Date 2019-02-20 19:18:47
     * @Param
     * @Return
     */
    @Override
    public List<ActivityDTO> listByCondition(ActivityDTO entity) {
        return super.listByCondition(entity);
    }

    /**
     * 查询活动信息详情信息
     * @Author lililiang
     * @Date 2019-02-20 19:18:47
     * @Param
     * @Return
     */
    @Override
    public ActivityDTO queryOneByPk(String id) {
        return super.queryOneByPk(id);
    }

    /**
     * 保存活动信息信息
     * @Author lililiang
     * @Date 2019-02-20 19:18:47
     * @Param
     * @Return
     */
    @Override
    @Transactional
    public Integer save(ActivityDTO entity) {
        if(entity.getId() == null){
            entity.setCreatetm(DateUtil.getNow());
            entity.setId(UuidUtil.getUuid());
            return mapper.add(entity);
        }else{
            return mapper.edit(entity);
        }
    }

    /**
     * 删除活动信息信息
     * @Author lililiang
     * @Date 2019-02-20 19:18:47
     * @Param
     * @Return
     */
    @Override
    @Transactional
    public Integer delete(String id) {
        return super.delete(id);
    }
}
